<?php

class ProfileMember extends MY_Controller {

    public function __construct() {
        parent::__construct();
    }

    function index() {
        $this->initForm();
        $this->data['editMode'] = false;
        $memberId = $this->session->userdata('memberID');
        $this->load->model("Member_Model");
        $this->data['data_member'] = $this->Member_Model->getMemberByID($memberId);

        $this->load->Model('Course_Permission_Model');
        $allCourseList = $this->Course_Permission_Model->getAllCourseByMemberID($memberId);

        $this->data['allCourseList'] = $allCourseList;

        $this->data['main_content'] = 'profile_member';
        $this->load->view('includes/template', $this->data);
    }

    function initForm() {
        $member = array(
            'username' => '',
            'password' => '',
            'confirmPwd' => '',
            'idCard' => '',
            'firstname' => '',
            'lastname' => '',
            'day' => '',
            'month' => '',
            'year' => '',
            'address' => '',
            'mobile' => '',
            'email' => '',
        );
        $this->data['member'] = $member;

        for ($i = 0; $i <= 30; $i++):
            $days[$i + 1] = $i + 1;
        endfor;

        $months = array(1 => "Jan",
            2 => "Feb",
            3 => "Mar",
            4 => "Apr",
            5 => "May",
            6 => "Jun",
            7 => "Jul",
            8 => "Aug",
            9 => "Sep",
            10 => "Oct",
            11 => "Nov",
            12 => "Dec");

        $time = time();
        for ($i = 0; $i <= 100; $i++):
            $years[date('Y', $time) - $i] = date('Y', $time) - $i;
        endfor;

        $username = array(
            'name' => 'signup_username'
        );

        $password = array(
            'name' => 'signup_password'
        );

        $confirmPwd = array(
            'name' => 'signup_confirmPwd'
        );

        $idCard = array(
            'name' => 'signup_idCard'
        );

        $firstname = array(
            'name' => 'signup_firstname'
        );

        $lastname = array(
            'name' => 'signup_lastname'
        );

        $day = 'class="styledselect-day" id="d"';
        $month = 'class="styledselect-month" id="m"';
        $year = 'class="styledselect-year" id="y"';

        $address = array(
            'name' => 'signup_address'
        );

        $mobile = array(
            'name' => 'signup_mobile'
        );

        $email = array(
            'name' => 'signup_email'
        );

        $this->data['username'] = $username;
        $this->data['password'] = $password;
        $this->data['confirmPwd'] = $confirmPwd;
        $this->data['idCard'] = $idCard;
        $this->data['firstname'] = $firstname;
        $this->data['lastname'] = $lastname;
        $this->data['day'] = $day;
        $this->data['month'] = $month;
        $this->data['year'] = $year;
        $this->data['address'] = $address;
        $this->data['mobile'] = $mobile;
        $this->data['email'] = $email;

        $this->data['days'] = $days;
        $this->data['months'] = $months;
        $this->data['years'] = $years;
    }

//    function editProfile(){
//        
//        $this->data['editMode'] = true;
//        $this->initForm();
//        $memberId = $this->session->userdata('memberID');
//        $this->load->model("Member_Model");
//        $this->data['data_member'] = $this->Member_Model->getMemberByID($memberId);
//        $this->data['main_content'] = 'profile_member';
//        $this->load->view('includes/template', $this->data);
//    }
//    function updateProfile(){
//        $member = array(
//			'USERNAME' => $this->input->post('signup_username'),
//			'FIRSTNAME' => $this->input->post('signup_firstname'),
//			'LASTNAME' => $this->input->post('signup_lastname'),
//			'DOB' => $this->input->post('signup_year').'-'.$this->input->post('signup_month').'-'.$this->input->post('signup_day'),
//                        'ID_CARD' => $this->input->post('signup_idCard'),
//			'ADDRESS' => $this->input->post('signup_address'),
//			'MOBILE' => $this->input->post('signup_mobile'),
//                        'EMAIL' => $this->input->post('signup_email')
//		);
//        $this->load->model("Member_Model");
//        $this->Member_Model->updateMember($member);
//        $this->data['editMode'] = false;
//        $memberId = $this->session->userdata('memberID');
//        $this->data['data_member'] = $this->Member_Model->getMemberByID($memberId);
//        $this->data['main_content'] = 'profile_member';
//        $this->load->view('includes/template', $this->data);
//    }
}

?>
